# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=giflib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=5.1.4
pkgrel=2
pkgdesc="A library for reading and writing gif images (mingw-w64)"
arch=('any')
url="https://sourceforge.net/projects/giflib"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "xmlto")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
source=("https://downloads.sourceforge.net/sourceforge/giflib/${_realname}-${pkgver}.tar.bz2"
        "giflib-5.0.4-include-stddef.patch")
sha256sums=('df27ec3ff24671f80b29e6ab1c4971059c14ac3db95406884fc26574631ba8d5'
            '32b9fbea6616db51df76b0872094b57a67fff1d8a338de5592773ff18fb1bf6f')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/giflib-5.0.4-include-stddef.patch"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  make bin_PROGRAMS=''
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" bin_PROGRAMS='' install
}
